package gameserver.model.gameobjects.stats.listeners;

import java.util.TreeSet;

import gameserver.model.gameobjects.Item;
import gameserver.model.gameobjects.player.Player;
import gameserver.model.gameobjects.stats.PlayerGameStats;
import gameserver.model.gameobjects.stats.id.ItemStatEffectId;
import gameserver.model.gameobjects.stats.modifiers.StatModifier;
import gameserver.model.templates.item.ItemTemplate;

import org.apache.log4j.Logger;

public class ItemEquipmentListener
{
	private static final Logger log = Logger.getLogger(ItemEquipmentListener.class);
	
	private static void onItemEquipment(ItemTemplate itemTemplate,int slot,PlayerGameStats pgs)
	{
		TreeSet<StatModifier> modifiers = itemTemplate.getModifiers();
		pgs.addModifiers(ItemStatEffectId.getInstance(itemTemplate.getTemplateId(), slot),modifiers);
	}
	
	public static void onItemEquipment(Item item, Player owner)
	{
		ItemTemplate itemTemplate = item.getItemTemplate();
		onItemEquipment(itemTemplate, item.getSlot(), owner.getGameStats());
	}
	
	public static void onItemUnEquipment(Item item,Player owner)
	{
		owner.getGameStats().endEffect(ItemStatEffectId.getInstance(item.getItemTemplate().getTemplateId(), item.getSlot()));
	}
}
